#ifndef _ATOMIC_0701_HJRD_H_
#define _ATOMIC_0701_HJRD_H_

/*------------------------ Include Begin --------------------------*/

// C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <time.h>
#include <ctype.h>

// C++
#include <iostream>
#include <fstream>
#include <chrono>
#include <string>
#include <random>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stdbool.h>
#include <sstream>

/*------------------------  Include End  -------------------------*/

/*------------------------  Service Info Begin  --------------------------*/
/**
 *
 * @name:     atomic_0701_hjrd
 * @chinese_name: 环境扰动补偿算法
 * @description: information atomic_0701_hjrd
 * @version: V1.0.0
 * @build_time: 2024-05-23 16:00:00
 * @license: MIT
 * @service_path: atomic_0701_hjrd
 *
 * @resource_requirement:
 *         + cpu_architecture: x86_64
 *         + memory: 4GB
 *         + hard_disk: 50GB
 *
 * @developer:
 *      +name: Spiderman
 *      +email: Spidermsan@atomic_0701_hjrd.com
 * @maintainer:
 *      +name: yishui
 *      +email:yishui@atomic_0701_hjrd.com
 * @operating_system:
 *      +name:Linux
 *      +v1:5.13.0-117-generic
 *      +v2:5.14.0-117-generic
 *      +name:SylixOS
 *      +v1:1.0.0
 *      +v2:1.0.2
 *
 *
 *
 */
/*------------------------  Service Info End  --------------------------*/

/*------------------------  Return Type Begin  --------------------------*/

#define ATOMIC_SERVICE_SUCCESS 0
#define ATOMIC_SERVICE_FAIL -1
#define ATOMIC_SERVICE_TIMEOUT -2
#define ATOMIC_SERVICE_ERROR -3
#define ATOMIC_SERVICE_NOT_SUPPORT -4
#define ATOMIC_SERVICE_NOT_READY -5
#define ATOMIC_SERVICE_NOT_INIT -6
#define ATOMIC_SERVICE_NOT_START -7
#define ATOMIC_SERVICE_NOT_STOP -8
#define ATOMIC_SERVICE_NOT_RELEASE -9
#define ATOMIC_SERVICE_NOT_DESTROY -10
#define ATOMIC_SERVICE_NOT_CREATE -11
#define ATOMIC_SERVICE_NOT_OPEN -12
#define ATOMIC_SERVICE_NOT_CLOSE -13
#define ATOMIC_SERVICE_NOT_READ -14
#define ATOMIC_SERVICE_NOT_WRITE -15
#define ATOMIC_SERVICE_NOT_SEEK -16
#define ATOMIC_SERVICE_NOT_TELL -17
#define ATOMIC_SERVICE_NOT_SIZE -18
#define ATOMIC_SERVICE_NOT_SEEK_END -19
#define ATOMIC_SERVICE_NOT_SEEK_SET -20
#define ATOMIC_SERVICE_NOT_SEEK_CUR -21
#define ATOMIC_SERVICE_NOT_SEEK_ABS -22

/*------------------------  Return Type End  --------------------------*/

/*------------------------  Message Info Begin  --------------------------*/

// 环境扰动补偿输入参数 (基本数据类型)
typedef struct {
    double pitch_command;        // 原始俯仰控制指令
    double yaw_command;         // 原始偏航控制指令
    double roll_command;       // 原始滚转控制指令
    double throttle_command;   // 原始油门控制指令
    double missile_velocity;    // 当前导弹速度(m/s)
    double missile_altitude;    // 当前导弹高度(m)
    double missile_angle;       // 当前导弹角度(度)
    double wind_speed;         // 风速(m/s)
    double wind_direction;     // 风向(度)
    double air_density;        // 空气密度(kg/m³)
    double temperature;        // 温度(℃)
    double humidity;           // 湿度(%)
    double turbulence_intensity; // 湍流强度(0-1)
    double timestamp;          // 时间戳(s)
} EnvironmentalCompensationInput;

// 环境扰动补偿输出参数 (基本数据类型)
typedef struct {
    double pitch_command;    // 补偿后俯仰指令
    double yaw_command;     // 补偿后偏航指令
    double roll_command;    // 补偿后滚转指令
    double throttle_command; // 补偿后油门指令
    double missile_velocity;      // X轴风效应
    double missile_altitude;      // Y轴风效应
    double missile_angle;      // Z轴风效应
    double turbulence_effect;  // 湍流效应
    double temperature_effect; // 温度效应
    double humidity_effect;    // 湿度效应
    double air_density_effect; // 空气密度效应
    double total_disturbance;  // 总扰动强度
    double max_actuator_rate; // 补偿效率(0-1)
    double adaptive_compensation; // 自适应补偿量
    double predictive_compensation; // 预测补偿量
    double nonlinear_compensation; // 非线性补偿量
} EnvironmentalCompensationOutput;

/*------------------------  Message Info End  --------------------------*/

// 风场模型
typedef struct {
    double speed;
    double direction;
    double altitude_factor;
    double turbulence;
} WindModel;


/*------------------------  Interface Declaration Begin  --------------------------*/


// 环境扰动补偿函数
int compensateEnvironmentalDisturbance(EnvironmentalCompensationInput *input,
                                       EnvironmentalCompensationOutput *output);

/*------------------------  Interface Declaration End  --------------------------*/

// 初始化风场模型
void initWindModel(WindModel *model, double speed, double direction, double turbulence);
// 更新风场模型
void updateWindModel(WindModel *model, double altitude, double timestamp);

#endif // _ATOMIC_0701_DDZT_H_
